﻿K_FORCEINLINE void SmmMath_Vec3_InitCoord(kVec3* pv, const kVec3* v, const kMat4* m, float f)
{
	pv->x = (v->x*m->_11 + v->y*m->_21 + v->z*m->_31 + m->_41)*f;
	pv->y = (v->x*m->_12 + v->y*m->_22 + v->z*m->_32 + m->_42)*f;
	pv->z = (v->x*m->_13 + v->y*m->_23 + v->z*m->_33 + m->_43)*f;
}

K_FORCEINLINE void SmmMath_Vec3_InitNormal(kVec3* pv, const kVec3* v, const kMat4* m, float f)
{
	pv->x = (v->x*m->_11 + v->y*m->_21 + v->z*m->_31)*f;
	pv->y = (v->x*m->_12 + v->y*m->_22 + v->z*m->_32)*f;
	pv->z = (v->x*m->_13 + v->y*m->_23 + v->z*m->_33)*f;
}

K_FORCEINLINE void SmmMath_Vec3_AddCoord(kVec3* pv, const kVec3* v, const kMat4* m, float f)
{
	pv->x += (v->x*m->_11 + v->y*m->_21 + v->z*m->_31 + m->_41)*f;
	pv->y += (v->x*m->_12 + v->y*m->_22 + v->z*m->_32 + m->_42)*f;
	pv->z += (v->x*m->_13 + v->y*m->_23 + v->z*m->_33 + m->_43)*f;
}

K_FORCEINLINE void SmmMath_Vec3_AddNormal(kVec3* pv, const kVec3* v, const kMat4* m, float f)
{
	pv->x += (v->x*m->_11 + v->y*m->_21 + v->z*m->_31)*f;
	pv->y += (v->x*m->_12 + v->y*m->_22 + v->z*m->_32)*f;
	pv->z += (v->x*m->_13 + v->y*m->_23 + v->z*m->_33)*f;
}

K_FORCEINLINE void SmmMath_Vec3_Normalize(kVec3*pv, const kVec3* v)
{
	float f = 1.0f / k_sqrt(v->x*v->x + v->y*v->y + v->z*v->z);
	pv->x = v->x*f;
	pv->y = v->y*f;
	pv->z = v->z*f;
}

K_FORCEINLINE void SmmMath_Vec4_Transform(kVec4* pv, const kVec4* left, const kMat4* right)
{
	pv->x = left->x*right->_11 + left->y*right->_21 + left->z*right->_31 + left->w*right->_41;
	pv->y = left->x*right->_12 + left->y*right->_22 + left->z*right->_32 + left->w*right->_42;
	pv->z = left->x*right->_13 + left->y*right->_23 + left->z*right->_33 + left->w*right->_43;
	pv->w = left->x*right->_14 + left->y*right->_24 + left->z*right->_34 + left->w*right->_44;
}

